/*
 * XYTCircle.java
 *
 * Created on September 20, 2004, 6:28 PM
 */

package edu.temple.GUS.MMA.Neighborhoods;

/**
 *
 * @author  jeffleon
 */
public class XYTCircle extends XYTNeighborhood {
    
    private int radius;

    private boolean filter[][][];
    
    /** Creates a new instance of XYTCircle */
    public XYTCircle( int r, int t) {

        // Define the dimensions of the filer
        super (2*r+1, 2*r+1, t);
        radius = r;

        // Create a circular filter
        filter = new boolean[t][2*radius+1][2*radius+1];
        
        float distance;
        int kernelXCoord;
        int kernelYCoord;
        
        kernelXCoord = r;
        kernelYCoord = r;
        
        for (int k=0; k<t; k++)
            for (int j=0; j<=2*radius; j++)
                for (int i=0; i<=2*radius; i++)
                {
                    distance = (float)Math.sqrt((j-kernelYCoord) * (j-kernelYCoord) + (i-kernelXCoord) * (i-kernelXCoord));
                    if ( distance <= (float)radius)
                        filter[k][j][i] = true;
                    else
                        filter[k][j][i] = false;
                }
    }
    
    public int getRadius() { return radius; }
    public void putRadius(int r) { radius = r; }
    public boolean getFilterElement(int x, int y, int t) { return filter[t][y][x];}
}
